/**
 * @file categories/dp/number_theory/uva11782/main.cpp
 * @brief
 * @see
 * @author Ruiming Guo (guoruiming@stu.scu.edu.cn)
 * @copyright 2022
 * @date 2022/7/3 15:42:23
 **/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const int N = 1e6 + 10;
const int INF = 0x3f3f3f3f;
vi prime;
bool vis[N];
double dp[N];
void get_prime() {
  vis[1] = true;
  for (int i = 2; i < N; ++i) {
    if (!vis[i]) prime.push_back(i);
    for (int j = 0; j < prime.size() && prime[j] * i < N; ++j) {
      vis[i * prime[j]] = true;
      if (i % prime[j] == 0) break;
    }
  }
}
double dfs(int x) {
  if (x == 1) return 0.0;
  if (vis[x]) return dp[x];
  vis[x] = true;
  int n = 0, m = 0;
  // 统计 n 和 m
  for (int i = 0; i < prime.size() && prime[i] <= x; ++i) {
    if (x % prime[i] == 0) {
      dp[x] += dfs(x / prime[i]);
      m++;
    }
    n++;
  }
  return dp[x] = (dp[x] + n) / m;
}
int main() {
  // High rating and good luck!
  int tc;
  cin >> tc;
  get_prime();
  for (int t = 1; t <= tc; ++t) {
    memset(vis, 0, sizeof(vis));
    memset(dp, 0, sizeof(dp));
    int n;
    scanf("%d", &n);
    printf("Case %d: %.10lf\n", t, dfs(n));
  }
  return 0;
}
